Skip to content

Commit 4c16188

Browse files
committed
improve naming of data parts of tables and dtos
1 parent 8e20548 commit 4c16188

File tree

17 files changed

+57
-876
lines changed

17 files changed

+57
-876
lines changed

AvaGui/Models/Metadata.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ public class MetadataModel
1010
{
1111
public MetadataModel(string originalName, uint originalChecksum)
1212
{
13-
OriginalName = originalName;
14-
OriginalChecksum = originalChecksum;
13+
DatName = originalName;
14+
DatChecksum = originalChecksum;
1515
}
1616

17-
public string OriginalName { get; }
18-
public uint OriginalChecksum { get; }
17+
public string DatName { get; }
18+
public uint DatChecksum { get; }
1919
public string? Description { get; set; }
2020

2121
public ICollection<TblAuthor> Authors { get; set; }

AvaGui/Models/ObjectEditorModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public bool TryLoadObject(FileSystemItem filesystemItem, out UiLocoFile? uiLocoF
235235
}
236236
}
237237

238-
metadata = new MetadataModel(locoObj.OriginalName, locoObj.OriginalChecksum)
238+
metadata = new MetadataModel(locoObj.DatName, locoObj.DatChecksum)
239239
{
240240
Description = locoObj.Description,
241241
Authors = locoObj.Authors,
@@ -392,7 +392,7 @@ async Task LoadObjDirectoryAsyncCore(string directory, IProgress<float> progress
392392
exception = true;
393393
}
394394

395-
if (exception || ObjectIndex?.Objects == null || ObjectIndex.Objects.Any(x => string.IsNullOrEmpty(x.Filename) || (x is ObjectIndexEntry xx && string.IsNullOrEmpty(xx.ObjectName))))
395+
if (exception || ObjectIndex?.Objects == null || ObjectIndex.Objects.Any(x => string.IsNullOrEmpty(x.Filename) || (x is ObjectIndexEntry xx && string.IsNullOrEmpty(xx.DatName))))
396396
{
397397
Logger.Warning("Index file format has changed or otherwise appears to be malformed - recreating now.");
398398
await RecreateIndex(directory, allFiles, progress);
@@ -429,8 +429,8 @@ public async Task CheckForDatFilesNotOnServer()
429429
Logger.Debug("Comparing local objects to object repository");
430430

431431
var localButNotOnline = ObjectIndex.Objects.ExceptBy(ObjectIndexOnline.Objects.Select(
432-
x => (x.ObjectName, x.Checksum)),
433-
x => (x.ObjectName, x.Checksum)).ToList();
432+
x => (x.DatName, x.Checksum)),
433+
x => (x.DatName, x.Checksum)).ToList();
434434

435435
if (localButNotOnline.Count != 0)
436436
{

AvaGui/ViewModels/FolderTreeViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ async Task LoadOnlineDirectoryAsync(bool useExistingIndex)
174174
Model.ObjectIndexOnline = new ObjectIndex()
175175
{
176176
Objects = (await Client.GetObjectListAsync(Model.WebClient, Model.Logger))
177-
.Select(x => new ObjectIndexEntry(x.UniqueId.ToString(), x.ObjectName, x.ObjectType, x.IsVanilla, x.Checksum, x.VehicleType))
177+
.Select(x => new ObjectIndexEntry(x.Id.ToString(), x.DatName, x.ObjectType, x.IsVanilla, x.DatChecksum, x.VehicleType))
178178
.ToList(),
179179
ObjectsFailed = []
180180
};
@@ -196,7 +196,7 @@ static List<FileSystemItemBase> ConstructTreeView(IEnumerable<ObjectIndexEntryBa
196196

197197
var groupedObjects = index
198198
.OfType<ObjectIndexEntry>() // this won't show errored files - should we??
199-
.Where(o => (string.IsNullOrEmpty(filenameFilter) || o.ObjectName.Contains(filenameFilter, StringComparison.CurrentCultureIgnoreCase)) && (displayMode == ObjectDisplayMode.All || (displayMode == ObjectDisplayMode.Vanilla == o.IsVanilla)))
199+
.Where(o => (string.IsNullOrEmpty(filenameFilter) || o.DatName.Contains(filenameFilter, StringComparison.CurrentCultureIgnoreCase)) && (displayMode == ObjectDisplayMode.All || (displayMode == ObjectDisplayMode.Vanilla == o.IsVanilla)))
200200
.GroupBy(o => o.ObjectType)
201201
.OrderBy(fsg => fsg.Key.ToString());
202202

@@ -211,7 +211,7 @@ static List<FileSystemItemBase> ConstructTreeView(IEnumerable<ObjectIndexEntryBa
211211
.OrderBy(vg => vg.Key.ToString()))
212212
{
213213
var vehicleSubNodes = new ObservableCollection<FileSystemItemBase>(vg
214-
.Select(o => new FileSystemItem(o.Filename, o.ObjectName, o.IsVanilla, fileLocation))
214+
.Select(o => new FileSystemItem(o.Filename, o.DatName, o.IsVanilla, fileLocation))
215215
.OrderBy(o => o.Name));
216216

217217
if (vg.Key == null)
@@ -230,7 +230,7 @@ static List<FileSystemItemBase> ConstructTreeView(IEnumerable<ObjectIndexEntryBa
230230
else
231231
{
232232
subNodes = new ObservableCollection<FileSystemItemBase>(objGroup
233-
.Select(o => new FileSystemItem(o.Filename, o.ObjectName, o.IsVanilla, fileLocation))
233+
.Select(o => new FileSystemItem(o.Filename, o.DatName, o.IsVanilla, fileLocation))
234234
.OrderBy(o => o.Name));
235235
}
236236

AvaGui/Views/MainWindow.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@
224224
<RowDefinition Height="Auto"/>
225225
</Grid.RowDefinitions>
226226
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Text="Original Name" Margin="4"/>
227-
<TextBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Text="{Binding OriginalName}" IsReadOnly="True" Margin="4" />
227+
<TextBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Text="{Binding DatName}" IsReadOnly="True" Margin="4" />
228228

229229
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Text="Original Checksum" Margin="4"/>
230-
<TextBox Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Text="{Binding OriginalChecksum}" IsReadOnly="True" Margin="4" />
230+
<TextBox Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Text="{Binding DatChecksum}" IsReadOnly="True" Margin="4" />
231231

232232
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Text="Description" Margin="4"/>
233233
<TextBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Text="{Binding Description}" IsReadOnly="True" Margin="4" />

Common/GlenDbSchema.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class GlenDBSchema2
1414

1515
public class GlenDbData
1616
{
17-
[JsonPropertyName("C00")] public string ObjectName { get; set; }
17+
[JsonPropertyName("C00")] public string DatName { get; set; }
1818
[JsonPropertyName("C01")] public string Image { get; set; }
1919
[JsonPropertyName("C02")] public string DescriptionAndFile { get; set; }
2020
[JsonPropertyName("C03")] public string ClassNumber { get; set; }
@@ -41,7 +41,7 @@ public class GlenDbData
4141

4242
public class GlenDbData2
4343
{
44-
[JsonPropertyName("C00")] public string ObjectName { get; set; }
44+
[JsonPropertyName("C00")] public string DatName { get; set; }
4545
[JsonPropertyName("C01")] public string Image { get; set; }
4646
[JsonPropertyName("C02")] public string DescriptionAndFile { get; set; }
4747
[JsonPropertyName("C03")] public string ObjectType { get; set; }

Dat/ObjectIndex.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public abstract record ObjectIndexEntryBase(string Filename);
101101

102102
public record ObjectIndexEntry(
103103
string Filename,
104-
string ObjectName,
104+
string DatName,
105105
ObjectType ObjectType,
106106
bool IsVanilla,
107107
uint32_t Checksum,

DatabaseExporter/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
.Include(l => l.Licence)
2525
.Select(x => new ExpandedTblLocoObject(x, x.Authors, x.Tags, x.Modpacks))
2626
.ToList()
27-
.OrderBy(x => x.Object.Name))
27+
.OrderBy(x => x.Object.UniqueName))
2828
{
2929
var obj = new ObjectMetadata(
30-
o.Object.OriginalName,
31-
o.Object.OriginalChecksum,
30+
o.Object.DatName,
31+
o.Object.DatChecksum,
3232
o.Object.Description,
3333
o.Authors.Select(a => a.Name).ToList(),
3434
o.Tags.Select(t => t.Name).ToList(),

DatabaseSeeder/Program.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ static void SeedDb(LocoDb db, bool deleteExisting)
121121
var index = ObjectIndex.LoadOrCreateIndex(ObjDirectory);
122122

123123
var objectMetadata = JsonSerializer.Deserialize<IEnumerable<ObjectMetadata>>(File.ReadAllText("Q:\\Games\\Locomotion\\Server\\objectMetadata.json"), jsonOptions);
124-
var objectMetadataDict = objectMetadata!.ToDictionary(x => (x.ObjectName, x.Checksum), x => x);
124+
var objectMetadataDict = objectMetadata!.ToDictionary(x => (x.DatName, x.Checksum), x => x);
125125

126126
var gameReleaseDate = new DateTimeOffset(2004, 09, 07, 0, 0, 0, TimeSpan.Zero);
127127

128-
foreach (var objIndex in index.Objects.DistinctBy(x => (x.ObjectName, x.Checksum)))
128+
foreach (var objIndex in index.Objects.DistinctBy(x => (x.DatName, x.Checksum)))
129129
{
130-
var metadataKey = (objIndex.ObjectName, objIndex.Checksum);
130+
var metadataKey = (objIndex.DatName, objIndex.Checksum);
131131
if (!objectMetadataDict.TryGetValue(metadataKey, out var meta))
132132
{ }
133133

@@ -141,10 +141,10 @@ static void SeedDb(LocoDb db, bool deleteExisting)
141141

142142
var tblLocoObject = new TblLocoObject()
143143
{
144-
Name = $"{objIndex.ObjectName}_{objIndex.Checksum}", // same as server upload name
144+
UniqueName = $"{objIndex.DatName}_{objIndex.Checksum}", // same as server upload name
145145
PathOnDisk = objIndex.Filename.Replace('\\', '/'), // make the path linux-compatible
146-
OriginalName = objIndex.ObjectName,
147-
OriginalChecksum = objIndex.Checksum,
146+
DatName = objIndex.DatName,
147+
DatChecksum = objIndex.Checksum,
148148
IsVanilla = objIndex.IsVanilla,
149149
ObjectType = objIndex.ObjectType,
150150
VehicleType = objIndex.VehicleType,
@@ -168,7 +168,7 @@ static void SeedDb(LocoDb db, bool deleteExisting)
168168
Console.WriteLine("Finished seeding");
169169
}
170170

171-
static Dictionary<(string ObjectName, string Checksum), GlenDbData2> LoadMetadata(string metadataFile)
171+
static Dictionary<(string DatName, string Checksum), GlenDbData2> LoadMetadata(string metadataFile)
172172
{
173173
if (!File.Exists(metadataFile))
174174
{
@@ -177,7 +177,7 @@ static void SeedDb(LocoDb db, bool deleteExisting)
177177

178178
var text = File.ReadAllText(metadataFile);
179179
var metadata = JsonSerializer.Deserialize<GlenDBSchema2>(text).data;
180-
var kvList = metadata.GroupBy(x => (x.ObjectName, uint32_t_LittleToBigEndian(x.Checksum)));
180+
var kvList = metadata.GroupBy(x => (x.DatName, uint32_t_LittleToBigEndian(x.Checksum)));
181181
return kvList.ToDictionary(x => x.Key, x => x.First());
182182
}
183183

Definitions/DTO/DtoLocoObject.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
namespace OpenLoco.Definitions.DTO
66
{
77
public record DtoLocoObject(
8-
int TblLocoObjectId,
9-
string Name,
10-
string OriginalName,
11-
uint OriginalChecksum,
8+
int Id,
9+
string UniqueName,
10+
string DatName,
11+
uint DatChecksum,
1212
string? OriginalBytes, // base64-encoded
1313
bool IsVanilla,
1414
ObjectType ObjectType,

Definitions/DTO/DtoObjectIndexEntry.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
namespace OpenLoco.Definitions.DTO
55
{
66
public record DtoObjectIndexEntry(
7-
int UniqueId,
8-
string ObjectName,
7+
int Id,
8+
string DatName,
9+
uint DatChecksum,
910
ObjectType ObjectType,
1011
bool IsVanilla,
11-
uint Checksum,
1212
VehicleType? VehicleType);
1313
}

0 commit comments

Comments
 (0)