Skip to content

Commit eaadf5a

Browse files
authored
Database object tables (#187)
* initial object table setup * climate object in database * adding more object tables * more tables * bugs * add script to fix object descriptions * add all object tables * add dtos and mappers * adding object route tests * .net 10 preview * fix all the datetime stuff * trying to make shit work
1 parent 929ca5a commit eaadf5a

File tree

239 files changed

+27317
-854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+27317
-854
lines changed

.editorconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ charset = utf-8
99
end_of_line = lf
1010
insert_final_newline = true
1111
trim_trailing_whitespace = true
12+
tab_width = 4
13+
indent_size = 4
1214
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
1315
dotnet_style_namespace_match_folder = true:suggestion
1416
dotnet_style_operator_placement_when_wrapping = beginning_of_line
@@ -21,8 +23,6 @@ dotnet_style_collection_initializer = true:suggestion
2123
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
2224
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
2325
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
24-
tab_width = 4
25-
indent_size = 4
2626
dotnet_style_explicit_tuple_names = true:suggestion
2727
dotnet_style_prefer_inferred_tuple_names = true:suggestion
2828
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
@@ -338,9 +338,9 @@ dotnet_diagnostic.CS8032.severity = none
338338
dotnet_diagnostic.CS8602.severity = warning # do not change: DAT treats this as error so we need to match it
339339

340340
dotnet_diagnostic.IDE0004.severity = suggestion
341-
dotnet_diagnostic.IDE0005.severity = suggestion
341+
dotnet_diagnostic.IDE0005.severity = error
342342
dotnet_diagnostic.IDE0009.severity = suggestion
343-
dotnet_diagnostic.IDE0010.severity = suggestion
343+
dotnet_diagnostic.IDE0010.severity = error
344344
dotnet_diagnostic.IDE0011.severity = suggestion
345345
dotnet_diagnostic.IDE0016.severity = suggestion
346346
dotnet_diagnostic.IDE0017.severity = suggestion

Common/Common.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<LangVersion>preview</LangVersion>
78
</PropertyGroup>
89

910
</Project>

Common/DateOnlyExtensions.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace Common
2+
{
3+
public static class DateOnlyExtensions
4+
{
5+
extension(DateOnly)
6+
{
7+
public static DateOnly Today
8+
=> DateOnly.FromDateTimeOffset(DateTimeOffset.UtcNow);
9+
10+
public static DateOnly FromDateTimeOffset(DateTimeOffset dateTimeOffset)
11+
=> DateOnly.FromDateTime(dateTimeOffset.DateTime);
12+
}
13+
14+
extension(DateOnly dateOnly)
15+
{
16+
public DateTimeOffset ToDateTimeOffset()
17+
=> new(dateOnly.Year, dateOnly.Month, dateOnly.Day, 0, 0, 0, TimeSpan.Zero);
18+
}
19+
}
20+
21+
// dummy helper class to get VS to detect the static property above
22+
// can remove this in VS 2022 17.16
23+
//public static class Foo
24+
//{
25+
// public static DateOnly Get() => DateOnly.Now;
26+
//}
27+
}

Common/VersionCheckBody.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ namespace OpenLoco.Common
55
public class VersionCheckBody
66
{
77
[JsonPropertyName("tag_name")]
8-
public string TagName { get; set; }
8+
public required string TagName { get; set; }
99
}
1010
}

Dat/Dat.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFramework>net9.0</TargetFramework>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<LangVersion>preview</LangVersion>
67
<ImplicitUsings>enable</ImplicitUsings>
78
<Nullable>enable</Nullable>
89
<AnalysisLevel>latest</AnalysisLevel>

Dat/Data/ObjectType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public enum ObjectType : byte
1212
TownNames,
1313
Cargo,
1414
Wall,
15-
TrainSignal,
15+
TrackSignal,
1616
LevelCrossing,
1717
StreetLight,
1818
Tunnel,
1919
Bridge,
20-
TrainStation,
20+
TrackStation,
2121
TrackExtra,
2222
Track,
2323
RoadStation,

Dat/FileParsing/AttributeHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Dat.Objects;
21
using OpenLoco.Dat.Data;
32
using OpenLoco.Dat.Objects;
43
using OpenLoco.Dat.Types;
@@ -59,8 +58,8 @@ public static Type TypeToStruct(ObjectType objectType)
5958
ObjectType.TownNames => typeof(TownNamesObject),
6059
ObjectType.TrackExtra => typeof(TrackExtraObject),
6160
ObjectType.Track => typeof(TrackObject),
62-
ObjectType.TrainSignal => typeof(TrainSignalObject),
63-
ObjectType.TrainStation => typeof(TrainStationObject),
61+
ObjectType.TrackSignal => typeof(TrackSignalObject),
62+
ObjectType.TrackStation => typeof(TrackStationObject),
6463
ObjectType.Tree => typeof(TreeObject),
6564
ObjectType.Tunnel => typeof(TunnelObject),
6665
ObjectType.Vehicle => typeof(VehicleObject),

Dat/FileParsing/SawyerStreamReader.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Dat.Objects;
21
using OpenLoco.Common.Logging;
32
using OpenLoco.Dat.Data;
43
using OpenLoco.Dat.Objects;
@@ -471,8 +470,8 @@ public static ILocoStruct GetLocoStruct(ObjectType objectType, ReadOnlySpan<byte
471470
ObjectType.TownNames => ByteReader.ReadLocoStruct<TownNamesObject>(data),
472471
ObjectType.TrackExtra => ByteReader.ReadLocoStruct<TrackExtraObject>(data),
473472
ObjectType.Track => ByteReader.ReadLocoStruct<TrackObject>(data),
474-
ObjectType.TrainSignal => ByteReader.ReadLocoStruct<TrainSignalObject>(data),
475-
ObjectType.TrainStation => ByteReader.ReadLocoStruct<TrainStationObject>(data),
473+
ObjectType.TrackSignal => ByteReader.ReadLocoStruct<TrackSignalObject>(data),
474+
ObjectType.TrackStation => ByteReader.ReadLocoStruct<TrackStationObject>(data),
476475
ObjectType.Tree => ByteReader.ReadLocoStruct<TreeObject>(data),
477476
ObjectType.Tunnel => ByteReader.ReadLocoStruct<TunnelObject>(data),
478477
ObjectType.Vehicle => ByteReader.ReadLocoStruct<VehicleObject>(data),

Dat/FileParsing/SawyerStreamWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using Dat.Objects;
21
using OpenLoco.Common.Logging;
32
using OpenLoco.Dat.Data;
3+
using OpenLoco.Dat.Objects;
44
using OpenLoco.Dat.Types;
55
using System.Text;
66

Dat/Objects/AirportObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using OpenLoco.Dat.Types;
44
using System.ComponentModel;
55

6-
namespace Dat.Objects
6+
namespace OpenLoco.Dat.Objects
77
{
88
[TypeConverter(typeof(ExpandableObjectConverter))]
99
[LocoStructSize(0x04)]

0 commit comments

Comments
 (0)