Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions OpenBVE.sln
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RouteViewer", "source\Route
ProjectSection(ProjectDependencies) = postProject
{06D89847-9C7A-47D5-8C7A-95AEBFFF5F1E} = {06D89847-9C7A-47D5-8C7A-95AEBFFF5F1E}
{081F5739-33DA-421A-B177-7B548D96646F} = {081F5739-33DA-421A-B177-7B548D96646F}
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E} = {3655732E-5A4F-4D88-B7C0-25BC3043BF8E}
{4B775819-3574-443E-95AD-B40BC6EA6469} = {4B775819-3574-443E-95AD-B40BC6EA6469}
{67418D38-1E2E-4944-A1B0-09E00FC2D055} = {67418D38-1E2E-4944-A1B0-09E00FC2D055}
{678031C7-6D87-4F5F-9C4A-12F86B76342C} = {678031C7-6D87-4F5F-9C4A-12F86B76342C}
Expand Down Expand Up @@ -187,6 +188,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KatoInput", "source\InputDe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZuikiInput", "source\InputDevicePlugins\ZuikiInput\ZuikiInput.csproj", "{73974327-132E-45CC-A278-7030DADB6242}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Route.LokSim", "source\Plugins\Route.Loksim\Route.LokSim.csproj", "{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -956,6 +959,24 @@ Global
{73974327-132E-45CC-A278-7030DADB6242}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{73974327-132E-45CC-A278-7030DADB6242}.Release|x86.ActiveCfg = Release|Any CPU
{73974327-132E-45CC-A278-7030DADB6242}.Release|x86.Build.0 = Release|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Debug|x86.ActiveCfg = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Debug|x86.Build.0 = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.GLMenu|Any CPU.ActiveCfg = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.GLMenu|Any CPU.Build.0 = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.GLMenu|Mixed Platforms.ActiveCfg = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.GLMenu|Mixed Platforms.Build.0 = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.GLMenu|x86.ActiveCfg = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.GLMenu|x86.Build.0 = Debug|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Release|Any CPU.Build.0 = Release|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Release|x86.ActiveCfg = Release|Any CPU
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -995,6 +1016,7 @@ Global
{C4BE7A1F-9CCD-4E78-8341-741ABDA8E026} = {D75531B7-000E-432E-A168-51846256A9D1}
{7ED7B285-FAE6-4B34-ACC5-87399F27C8BC} = {16553295-E70F-4596-AA78-848EEA576C4A}
{BA9949E2-47BE-4308-AD66-1314853FDC49} = {851ADF1E-4500-4A14-B4AA-C1087A6C537E}
{3655732E-5A4F-4D88-B7C0-25BC3043BF8E} = {D75531B7-000E-432E-A168-51846256A9D1}
{73974327-132E-45CC-A278-7030DADB6242} = {851ADF1E-4500-4A14-B4AA-C1087A6C537E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
13 changes: 13 additions & 0 deletions assets/Compatibility/Loksim/Grass.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CreateMeshBuilder,,,
AddVertex,-450,0,10
AddVertex,-450,-0.01,0
AddVertex,450,-0.01,0
AddVertex,450,-0.01,10
AddFace,3,2,1,0

LoadTexture,Grass.png,,
SetTextureCoordinates,0,0,0
SetTextureCoordinates,1,1,0
SetTextureCoordinates,2,1,30
SetTextureCoordinates,3,0,30

Binary file added assets/Compatibility/Loksim/grass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions source/LibRender2/BaseRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,11 @@ public void RenderFace(Shader shader, ObjectState state, MeshFace face, bool deb
break;
}

if ((face.Flags & FaceFlags.DisableDepthWrite) != 0)
{
GL.DepthMask(false);
}

// blend factor
float distanceFactor;
if (material.GlowAttenuationData != 0)
Expand Down Expand Up @@ -1516,6 +1521,7 @@ public void RenderFace(Shader shader, ObjectState state, MeshFace face, bool deb
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
}
lastObjectState = state;
GL.DepthMask(true);
}

/// <summary>Sets the current MouseCursor</summary>
Expand Down
2 changes: 1 addition & 1 deletion source/LibRender2/Objects/ObjectLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private void RemoveObject(ObjectState state)
{
lock (LockObject)
{
if (Objects.TryRemove(state, out _))
if (state != null && Objects.TryRemove(state, out _))
{
myOpaqueFaces.RemoveAll(x => x.Object == state);
myAlphaFaces.RemoveAll(x => x.Object == state);
Expand Down
21 changes: 21 additions & 0 deletions source/OpenBVE/UserInterface/formMain.Start.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,27 @@ private void PopulateRouteList(string routeFolder, ListView listView, bool packa
}
}
break;
case ".l3dfpl":
fileName = System.IO.Path.GetFileName(Files[i]);
if (fileName == null)
{
continue;
}

if (!Program.CurrentHost.LoadPlugins(Program.FileSystem, Interface.CurrentOptions, out _, Program.TrainManager, Program.Renderer))
{
throw new Exception("Unable to load the required plugins- Please reinstall OpenBVE");
}
for (int j = 0; j < Program.CurrentHost.Plugins.Length; j++)
{
if (Program.CurrentHost.Plugins[j].Route != null && Program.CurrentHost.Plugins[j].Route.CanLoadRoute(Files[i]))
{
Item = listView.Items.Add(fileName);
Item.ImageKey = @"loksim";
Item.Tag = Files[i];
}
}
break;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion source/OpenBveApi/Objects/FaceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum FaceFlags : byte
/// <summary>The mask used for unidirectional Face commands</summary>
FaceTypeMask = 7,
/// <summary>The mask used for bidirectional Face2 commands</summary>
Face2Mask = 8
Face2Mask = 8,
DisableDepthWrite = 16,
}
}
3 changes: 2 additions & 1 deletion source/OpenBveApi/Objects/Helpers/MeshBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public void Apply(ref StaticObject Object, bool EnableHacks = false, bool Ignore
if (Materials[i].TransparencyTexture != null)
{
currentHost.LoadTexture(Materials[i].TransparencyTexture, new TextureParameters(null, null), out transparency);
currentHost.LoadTexture(ref transparency, OpenGlTextureWrapMode.ClampClamp);
// FIXME: CRASHES SOMETIMES
//currentHost.LoadTexture(ref transparency, OpenGlTextureWrapMode.ClampClamp);
}

TextureParameters parameters;
Expand Down
4 changes: 4 additions & 0 deletions source/OpenBveApi/Routes/QuadTree/QuadNode.Leaf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ internal void UpdateBoundingRectangle(ObjectState objectState, Vector3 quadPosit
Vector3 absolutePosition = quadCenter + quadPosition;
for (int i = 0; i < objectState.Prototype.Mesh.Vertices.Length; i++)
{
if (objectState.Prototype.Mesh.Vertices[i] == null)
{
return;
}
Vector3 vector = absolutePosition + Vector3.Rotate(objectState.Prototype.Mesh.Vertices[i].Coordinates, quadOrientation);
if (vector.X < BoundingRectangle.Left)
{
Expand Down
1 change: 1 addition & 0 deletions source/OpenBveApi/System/Path.Loksim3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static class Loksim3D
/// <returns></returns>
public static string CombineFile(string absolute, string relative, string packageDirectory)
{
relative = relative.TrimStart('\\');
try
{
string file = Path.CombineFile(absolute, relative);
Expand Down
14 changes: 14 additions & 0 deletions source/Plugins/Formats.OpenBve/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,20 @@ public virtual bool GetEnumValue<T3>(T2 key, out T3 enumValue, out int index, ou
return false;
}

/// <summary>Unconditionally gets the next value as a string</summary>
public virtual void GetNextValue(out T2 valueType, out string value)
{
if (keyValuePairs.Count > 0)
{
valueType = keyValuePairs.Keys.First();

keyValuePairs.TryRemove(valueType, out KeyValuePair<int, string> v);
value = v.Value;
}
valueType = default;
value = string.Empty;
}

/// <summary>Reads the specified Enum value from the block</summary>
public virtual bool GetEnumValue<T3>(T2 key, out T3 enumValue, out Color32 color) where T3 : struct, Enum
{
Expand Down
115 changes: 115 additions & 0 deletions source/Plugins/Formats.OpenBve/Enums/Loksim/LoksimAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
namespace Formats.OpenBve
{
public enum LoksimAttribute
{
Unknown = 0,
// Common attributes
FileAuthor,
FileInfo,
FilePicture,
FileDoku,
Name,
File,
Value,
// Kurbuchstrecken only
KBS,
BremsArt,
BremsStellung,
WetterDatei,
Zeiten,
ZugArt,
ZugGewicht,
ZugLaenge,
ZugLimit,
// StartPunkt only
Gleis,
Pos,
Richtung,
Strecke,
// Station only
Abfahrt,
Ankunft,
Bedarfshalt,
Betriebshalt,
Haltdauer,
Haltepunkt,
DistanzSoundVorBedarfsHalt,
DistanzSoundVorHalt,
SignalVorAusfahrt,
SignalVorEinfahrt,
SoundAbfahrt,
SoundAnkunft,
SoundAnsage,
SoundHalt,
SoundVorBedarfsHalt,
SoundVorHalt,
Tueren,
Zugfolgestelle,
// Connection
Ende1,
Ende2,
Gleis1,
Gleis2,
Strecke1,
Strecke2,
// Eintrag
Abstand,
Anzahl,
Datei,
GleisHoeheFolgen,
HoeheLand,
Position,
Verschiebung,
WeitSichtbar,
Winkel,
// Strecke
StartPunkt,
EndPunkt,
ParallelGleis,
ParallelStart,
ParallelEnd,
ParallelAbstand,
StartPos,
Typ,
WeicheEnd,
WeicheGleis,
WeicheGleisPos,
Offset,
Qualitaet,
RollMaterial,
DynamicVisibility,
FixedDynamicVisibility,
StreckenAbhaengigkeit,
KILOMETER,
DayLight,
NightLight,
LokLight,
SRAND,
XValue,
YValue,
ZValue,
Polygon,
Scale,
TextureFile,
Texture,
Zwischenpunkte,
Hoehe,
Hoehefrei,
// KURVE
Start,
Ende,
SanfterWinkel,
// STEIGUNG
Promille,
//L3DRail
Transparent,
Spurbreite,
Schienenbreite,
Schienenhoehe,
Bettungsbreite,
x1,
x2,
y1,
y2,
}
}
46 changes: 46 additions & 0 deletions source/Plugins/Formats.OpenBve/Enums/Loksim/LoksimNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace Formats.OpenBve
{
public enum LoksimNode
{
// Common
Props,
Random,
Name,
// Fahrplan
PneuBremse,
MgBremse,
Haltestellen,
Halt,
// Kursbuchstrecken
Strecken,
Strecke,
Verbindung,
StartPunkt,
WeichenStellung,
// Strecke
DefaulRail,
StdTexture,
Himmelsrichtung,
GLEIS,
TOPOLOGIE,
Erstellung,
KURVE,
STEIGUNG,
Weiche,
Kreuzung,
Ausweiche,
Landschaft,
Landschaftsobjekt,
// Objecte
Objecte,
Object,
Eintrag,
Eigenschaften,
Lightning,
// L3DRail
Hoehe,
TexSchieneOben,
TexSchieneSeite,
TexBettung
}
}
3 changes: 3 additions & 0 deletions source/Plugins/Formats.OpenBve/Formats.OpenBve.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
<Compile Include="Enums\ExtensionsCfg\ExtensionsCfgSection.cs" />
<Compile Include="Enums\HUD\HUDKey.cs" />
<Compile Include="Enums\HUD\HUDSection.cs" />
<Compile Include="Enums\Loksim\LoksimAttribute.cs" />
<Compile Include="Enums\Loksim\LoksimNode.cs" />
<Compile Include="Enums\MarkerScript\MarkerScriptKey.cs" />
<Compile Include="Enums\MarkerScript\MarkerScriptSection.cs" />
<Compile Include="Enums\PatchDatabase\PatchDatabaseKey.cs" />
Expand All @@ -88,6 +90,7 @@
<Compile Include="Enums\Panel2\Panel2Subject.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XML\XMLFile.cs" />
<Compile Include="XML\XMLFileAttributes.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OpenBveApi\OpenBveApi.csproj">
Expand Down
Loading